package com.adaxi.adc.business.passengertrip.config;

import com.adaxi.adc.business.passengertrip.filter.GateWayWallIntercepter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author 涛哥
 * @version 1.0
 */
@EnableWebMvc
@Configuration
public class SpringMvcConfig implements WebMvcConfigurer {


    @Autowired
    GateWayWallIntercepter gateWayWallIntercepter;



    /**
     * 静态资源的
     * <img src="http://localhost:8080/static/image.jpg" />
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("swagger-ui.html")
                .addResourceLocations(
                        "classpath:/META-INF/resources/");
        registry.addResourceHandler("/webjars/**")
                .addResourceLocations(
                        "classpath:/META-INF/resources/webjars/");
        // WebMvcConfigurer.super.addResourceHandlers(registry);
    }


    /**
     * 添加拦截器
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(gateWayWallIntercepter)
                .addPathPatterns("/**")
                .excludePathPatterns("/login","/register","/addPassenger","/passenger/query/**");

    }

}
